import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:kq_flutter_tv_widgets/widgets/formItem/entity/kq_form_entity.dart';
import 'package:kq_flutter_tv_widgets/widgets/formItem/kq_header_item_view.dart';
import 'package:kq_flutter_tv_widgets/widgets/wrapFlow/kq_wrap_flow.dart';

import '../../resources/Images.dart';

class WrapFlowPage extends StatefulWidget {
  const WrapFlowPage({super.key});

  @override
  State<WrapFlowPage> createState() => _WrapFlowPageState();
}

class _WrapFlowPageState extends State<WrapFlowPage> {
  @override
  Widget build(BuildContext context) {
    List<Map<String, String>> items = [
      {'icon': Images.commonIcAddRemake, 'text': '参加阿克琉斯剪短发'},
      {'icon': Images.commonIcAddRemake, 'text': '参加阿克发'},
      {'icon': Images.commonIcAddRemake, 'text': 'asss阿克发'},
      {'icon': Images.commonIcAddRemake, 'text': '1234'}
    ];
    return Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          KqHeaderItemView(entity: KqFormEntity(title: '网格：文本+文本样式--3等份')),
          KqWrapFlow(
            crossAxisCount: 3,
            needDrawCallback: (index) {
              if (index > 7) {
                return false;
              }
              return true;
            },
            renderTextMaxLineCallback: (index) {
              if (index == 0) {
                return 2;
              }
              return 1;
            },
            flowType: FlowType.textTextFlowType,
            leftItemMaxWidth: 100,
            renderLeftTextCallback: (index) {
              if (index == 0) {
                return "物料编码:";
              } else if (index == 1) {
                return "供应商:";
              } else if (index == 2) {
                return "批次号:";
              } else if (index == 3) {
                return "条码:";
              } else if (index == 4) {
                return "日期:";
              } else if (index == 5) {
                return "位置:";
              } else if (index == 6) {
                return "创建人:";
              } else if (index == 7) {
                return "任务:";
              }
              return "备注:";
            },
            renderRightTextCallback: (index) {
              if (index == 0) {
                return "aldsjfiajoi2929";
              } else if (index == 1) {
                return "kq";
              } else if (index == 2) {
                return "1283";
              } else if (index == 3) {
                return "ladifjsssssssss";
              } else if (index == 4) {
                return "2023-2-22";
              } else if (index == 5) {
                return "zhongjian";
              } else if (index == 6) {
                return "w";
              } else if (index == 7) {
                return "t";
              }
              return "alkdjflkajdflkjslkfjalsdjfss";
            },
            // itemWithRaleCallback: (index, crossAxisIndex) {
            //   if (crossAxisIndex == 0) {
            //     return 0.5;
            //   } else if (crossAxisIndex == 1) {
            //     return 0.3;
            //   }
            //   return 0.2;
            // },
            itemWithWidthCallback: (index, crossAxisIndex) {
              if (crossAxisIndex == 0) {
                return 150;
              } else if (crossAxisIndex == 1) {
                return 120;
              }
              return 60;
            },
          ),
          KqHeaderItemView(entity: KqFormEntity(title: '网格：icon+文本样式--3等份')),
          KqWrapFlow(
            crossAxisCount: 3,
            leftItemMaxWidth: 15,
            totalCountCallback: () => items.length,
            renderTextMaxLineCallback: (index) {
              if (index == 0) {
                return 2;
              }
              return 1;
            },
            flowType: FlowType.iconTextFlowType,
            renderIconPathCallback: (index) {
              Map<String, String> item = items[index];
              return item['icon'] ?? '';
            },
            renderRightTextCallback: (index) {
              Map<String, String> item = items[index];
              return item['text'] ?? '';
            },
            // itemWithRaleCallback: (index, crossAxisIndex) {
            //   if (crossAxisIndex == 0) {
            //     return 0.5;
            //   } else if (crossAxisIndex == 1) {
            //     return 0.3;
            //   }
            //   return 0.2;
            // },
            itemWithWidthCallback: (index, crossAxisIndex) {
              if (crossAxisIndex == 0) {
                return 150;
              } else if (crossAxisIndex == 1) {
                return 120;
              }
              return 60;
            },
          ),
        ],
      ),
    );
  }
}
